package com.example.Lezedata.util;

import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.example.Lezedata.GBApplication;
import com.example.Lezedata.R;

public class GBToast {
    public static void shortToast(String msg) {
        Toast(msg,Gravity.CENTER,Toast.LENGTH_SHORT);
    }

    public static void longToast(String msg) {
        Toast(msg,Gravity.CENTER,Toast.LENGTH_LONG);
    }

    public static void showErrorToast(String msg) {
        Toast(msg,Gravity.CENTER,Toast.LENGTH_SHORT);
    }

    static void Toast(String msg ,int gravity , int duration){
        View view = LayoutInflater.from(GBApplication.getContext()).inflate(R.layout.toast,null,false);
        TextView textView = view.findViewWithTag("text");
        textView.setText(msg);
        Toast toast = new Toast(GBApplication.getContext());
        toast.setDuration(duration);
        toast.setView(view);
        toast.setGravity(gravity,0,40);
        toast.show();
    }
}
